package org.libl.web.servlet.student;

import org.libl.domain.Student;
import org.libl.service.student.StudentService;
import org.libl.service.student.impl.StudentServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/student/FindAllStudentController")
public class StudentFindAllController extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
        //1.创建业务层对象
        StudentService service = new StudentServiceImpl();
        //2.调用业务层查询所有方法,保存到域对象,转发到显示所有学生页面
        List<Student> all = service.findAll();
        request.setAttribute("list",all);
        request.getRequestDispatcher("/student/listCustomer.jsp").forward(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
        doPost(request, response);
    }
}
